package com.zyh.work2

trait MathTool {
  def fact(m:Int):Long//阶乘
  def intPower(m:Int,n:Int):Long//m的n次方
  def findFactor(m:Int,n:Int):Boolean//参数和是否大于100
}
class MathTest extends MathTool{
  override def fact(m: Int): Long = {
    if(m==0) 1
    else fact(m-1)*m
  }

  override def intPower(m: Int, n: Int): Long = {
    var num:Int = 1
    for(i <- 1 to n) num *= m
    num
  }

  override def findFactor(m: Int, n: Int): Boolean = {
    m+n>100
  }
}
object TraitTest{
  def main(args: Array[String]): Unit = {
    val test = new MathTest
    println(test.fact(5))
    println(test.intPower(10,2))
    println(test.findFactor(50,50))
  }
}